<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Resetip extends CI_Controller {
    function  __construct(){
        parent::__construct(); 
        if(!($this->session->userdata('logedin')&&$this->session->userdata('admin')==1)){
            redirect('ad_user');            
            exit();
        }
              
    }
    function test(){
        $startdate = '2012-11-12 23:05:48';
       echo  date('Y-m-d H:i:s',strtotime( $startdate ));
    }
    function index($offset=0){  
        $startdate=$endate=$thongbao='';
        if($_POST){            
            $startdate =trim($this->input->post('startdate',true));
            $endate = trim($this->input->post('enddate',true));
            if(!empty($startdate)){
                $where['created >='] = date('Y-m-d H:i:s',strtotime( $startdate ));
            }
            if(!empty($endate)){
                $where['created <='] = date('Y-m-d H:i:s',strtotime( $endate ));
            }
            $this->db->where($where);
            $this->db->update('users',array('ip'=>0));
            $thongbao = 'Reset Done !';
        }
        
         
        $data->content=$this->load->view('reset',
                        array(
                        'start'=>$startdate,
                        'end'=>$endate,
                        'thongbao'=>$thongbao                            
                        ),true);        
        $dt = $this->template->render($data);  
        $this->load->view('default/viewfull',$dt);      
        
    }

   
    
}